Skip to content

Restore recipe parameters functionality#3530

Merged
zanesq merged 23 commits intomainfrom
zane/recipe-parameters
Jul 22, 2025
Merged

Restore recipe parameters functionality#3530
zanesq merged 23 commits intomainfrom
zane/recipe-parameters

Conversation

@zanesq
Copy link
Collaborator

@zanesq zanesq commented Jul 20, 2025

Recipe parameters stopped working after the new ui launch.

This adds them back and fixes some issues I noticed along the way:

  1. Navigating away from an active recipe in chat and back to chat now keeps your chat showing rather than trying to reload the recipe from scratch.
  2. Clicking on working directory or other buttons in the chat area no longer auto submits the chat form.

Bonus:

  • Added a few more parameter form fields while I was in there select, boolean and number.
  • Added the remaining recipe fields in the preview modal with a deeplink for easy sharing.
Screenshot 2025-07-19 at 5 48 51 PM Screenshot 2025-07-19 at 5 49 39 PM Screenshot 2025-07-19 at 5 50 10 PM image image

"format": "double",
"description": "Cost per token for output (optional)",
"nullable": true
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream changes can ignore

* Cost per token for output (optional)
*/
output_token_cost?: number | null;
/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream changes can ignore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we maybe have something in CI that checks whether regenerating the openapi.json is a no-op?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if ci can help this other than maybe flagging when someone didn't manually generate it? It should be manually generated whenever someone makes a related change. I run the full npm run start locally which generates the types so occasionally I run into this issue where someone didn't generate the types upstream.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I meant we could run the typegen in ci and compare if it changes anything and if it does, tell the user they forgot to run it but did make a change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha, good idea! Will follow up with that 👍

)}
</div>
{/* Input row with inline action buttons wrapped in form */}
<form onSubmit={onFormSubmit} className="relative flex items-end">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

form now wraps only what it should, the input and the submit/action buttons, before it was wrapping all the actions under the chat input causing the chat form to submit from descendant buttons in launched modals or the working directory click

{error.message || 'Honk! Goose experienced an error while responding'}
</div>

{/* Expandable Error Details */}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this expandable error details area as it wasn't providing any other useful context than what is displayed on the screen.

@DOsinga DOsinga self-requested a review July 20, 2025 08:54
Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for jumping on this. I added some maybe too detailed review for a quick fix. In general my question is also, what can we do to test this automatically? these flows are hard to follow I find and seem like having bugs in them would be easy

* Cost per token for output (optional)
*/
output_token_cost?: number | null;
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we maybe have something in CI that checks whether regenerating the openapi.json is a no-op?

if (recipeConfig?.title && recipeConfig.title !== currentRecipeTitle) {
// Only reset usage if we're switching between different recipes
// Don't reset if we're going from no recipe to a recipe (initial load)
// or if we already have messages (ongoing conversation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have this comment because the code is hard to follow; let's see if we can fix that and drop the comment instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call refactored and simplified

// Reset recipe usage tracking when recipe changes
useEffect(() => {
if (recipeConfig?.title !== currentRecipeTitle) {
const previousTitle = currentRecipeTitle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to move this outside the if, so the comparisons are easier to follow

// Only reset usage if we're switching between different recipes
// Don't reset if we're going from no recipe to a recipe (initial load)
// or if we already have messages (ongoing conversation)
if (previousTitle && recipeConfig?.title && previousTitle !== recipeConfig.title) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and below, we already checked previousTitle != recipeConfig.title so that bit is always going to be true. So for this to not be true, either previousTitle or recipeConfig?title needs to be falsey. if that's the case we should check on that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed

parameters.forEach((param) => {
if (param.default) {
initialValues[param.key] = param.default;
// Set default value for optional parameters if they have a default value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the comment here

if (!allParams.some((param) => param.key === promptParam.key)) {
allParams.push(promptParam);
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is O(n^2) - consider using a map to do this more efficiently

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed

const formattedParam: Parameter = {
key: param.key,
input_type: 'string',
input_type: param.input_type || 'string', // Use actual input_type instead of hardcoded 'string'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment


// Pre-fill input with recipe prompt instead of auto-sending it
const initialPrompt = useMemo(() => {
// Don't show initial prompt if we already have messages (ongoing conversation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we calling this in the wrong place? the initial prompt shouldn't change because we have a conversation, we should just not put at as the non-initial prompt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed

setRecipeParameters(inputValues);
// Store parameters in chat context instead of local state
if (chatContext?.setRecipeParameters) {
chatContext.setRecipeParameters(inputValues);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what case is chatContext undefined here? can we use the type system to make sure it is not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a provider that we only use for certain cases at runtime so the type system isn't enough to catch it unfortunately

| string; // Can also be a string representation
// Properties added for scheduled execution
scheduledJobId?: string;
isScheduledExecution?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for now, but we have this definition also on the server. for some reason we're not using the openapi mechanism to do recipe calls, so we duplicate the definition here. do you think we can fix that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, went ahead and added it to the openai types

@zanesq
Copy link
Collaborator Author

zanesq commented Jul 21, 2025

@DOsinga great review thanks! All issues addressed pls take another look.

Regarding how we can verify, unfortunately until there are more functional/ui tests covering this process its a manual testing process. I'll make sure we cover recipes in the tests as we build them out.

@zanesq zanesq requested a review from DOsinga July 21, 2025 20:50
messageHistoryIndex: number;
messages: Message[];
recipeConfig?: Recipe | null; // Add recipe configuration to chat state
recipeParameters?: Record<string, string> | null; // Add recipe parameters to chat state
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are hub and pair having the same diff & code here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch also, refactored to use a shared ChatType instead 👍

@DOsinga
Copy link
Collaborator

DOsinga commented Jul 22, 2025

hmm, weird error. can you try merging in main?

zanesq added 3 commits July 22, 2025 08:47
…ters

* 'main' of github.com:block/goose:
  Add recipe install warning (#3537)
  Replace mcp_core::resource::* with rmcp types (#3563)
  Add YouTube video embed to using-goosehints.md (#3560)
  fix: ensure retry-config and success-criteria are populated in openapi spec (#3575)
  fix: use sequential when sub recipe task is 1. (#3573)
  fix: track message id to keep like with like (#3572)
  Replace mcp_core::prompt with rmcp::model types (#3561)
  feat (ui): close recipe modals with esc key (#3568)
  feat: recipes can retry with success criteria (#3474)
  Env var to set Ollama request timeout (#3516)
…zane/recipe-parameters

* 'zane/recipe-parameters' of github.com:block/goose:
  Add recipe install warning (#3537)
  Replace mcp_core::resource::* with rmcp types (#3563)
  Add YouTube video embed to using-goosehints.md (#3560)
  fix: ensure retry-config and success-criteria are populated in openapi spec (#3575)
  fix: use sequential when sub recipe task is 1. (#3573)
  fix: track message id to keep like with like (#3572)
  Replace mcp_core::prompt with rmcp::model types (#3561)
  feat (ui): close recipe modals with esc key (#3568)
  feat: recipes can retry with success criteria (#3474)
  Env var to set Ollama request timeout (#3516)
@zanesq zanesq merged commit 246ba19 into main Jul 22, 2025
7 of 8 checks passed
@zanesq zanesq deleted the zane/recipe-parameters branch July 22, 2025 17:31
katzdave added a commit that referenced this pull request Jul 22, 2025
* 'main' of github.com:block/goose: (23 commits)
  fix: add fallback id to messages if none provided (#3584)
  feat: migrate ErrorData from internal mcp crates to rmcp version (#3586)
  fix: adjust subrecipe description to allow running tests (#3585)
  Scenario tests (#3430)
  feat: migrate JsonRpcMessage/Request/Response/Error/Notification from internal mcp crates to rmcp versions (#3564)
  Restore recipe parameters functionality (#3530)
  feat: Enhanced loading states with thinking icons and flying bird animation (#3478)
  Agent loop defensive (#3554)
  chore: remove needless clone() in goose/providers (#2528)
  Add recipe install warning (#3537)
  Replace mcp_core::resource::* with rmcp types (#3563)
  Add YouTube video embed to using-goosehints.md (#3560)
  fix: ensure retry-config and success-criteria are populated in openapi spec (#3575)
  fix: use sequential when sub recipe task is 1. (#3573)
  fix: track message id to keep like with like (#3572)
  Replace mcp_core::prompt with rmcp::model types (#3561)
  feat (ui): close recipe modals with esc key (#3568)
  feat: recipes can retry with success criteria (#3474)
  Env var to set Ollama request timeout (#3516)
  Updating docs to match new UI (#3552)
  ...
michaelneale added a commit that referenced this pull request Jul 23, 2025
* main:
  docs: desktop recipe format (#3594)
  Fix model display name not being updated immediately after leaving settings (#3587)
  Added option to summarize the chat when an error is triggered (#3598)
  Remove mcp_macros and unused types (#3581)
  fix: add fallback id to messages if none provided (#3584)
  feat: migrate ErrorData from internal mcp crates to rmcp version (#3586)
  fix: adjust subrecipe description to allow running tests (#3585)
  Scenario tests (#3430)
  feat: migrate JsonRpcMessage/Request/Response/Error/Notification from internal mcp crates to rmcp versions (#3564)
  Restore recipe parameters functionality (#3530)
  feat: Enhanced loading states with thinking icons and flying bird animation (#3478)
  Agent loop defensive (#3554)
  chore: remove needless clone() in goose/providers (#2528)
  Add recipe install warning (#3537)
  Replace mcp_core::resource::* with rmcp types (#3563)
  Add YouTube video embed to using-goosehints.md (#3560)
  fix: ensure retry-config and success-criteria are populated in openapi spec (#3575)
taylorkmho added a commit that referenced this pull request Jul 23, 2025
* main:
  feat: subagent turn count, simple agent loop (#3597)
  feat: subagent independent extension manager (#3596)
  Improve session history loading resiliency (#3588)
  Added logging and changed default route case to not redirect to home when there is an invalid route (#3610)
  fix: chat sidebar layout overlapping content occasionally (#3590)
  fix: loading shared sessions (#3607)
  docs: use installer component for tutorial, add updating extensions section (#3608)
  fix: show token alert popover during agent responses and agent failure cases (#3536)
  reuse the cancellation token in the agent level (#3599)
  Docs: Move MongoDB tutorial to MCP section (#3602)
  docs: desktop recipe format (#3594)
  Fix model display name not being updated immediately after leaving settings (#3587)
  Added option to summarize the chat when an error is triggered (#3598)
  Remove mcp_macros and unused types (#3581)
  fix: add fallback id to messages if none provided (#3584)
  feat: migrate ErrorData from internal mcp crates to rmcp version (#3586)
  fix: adjust subrecipe description to allow running tests (#3585)
  Scenario tests (#3430)
  feat: migrate JsonRpcMessage/Request/Response/Error/Notification from internal mcp crates to rmcp versions (#3564)
  Restore recipe parameters functionality (#3530)
zanesq added a commit that referenced this pull request Jul 23, 2025
@zanesq zanesq restored the zane/recipe-parameters branch July 23, 2025 23:33
atarantino pushed a commit to atarantino/goose that referenced this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants